package com.wanjia.bpsapi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wanjia.bpsapi.pojo.dto.WjSupplierName;
import com.wanjia.bpsapi.pojo.entity.WjStoreProduct;
import com.wanjia.bpsapi.pojo.entity.WjSupplier;
import com.wanjia.bpsapi.mapper.WjSupplierMapper;
import com.wanjia.bpsapi.service.IWjSupplierService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 供应商表---二次升级 服务实现类
 * </p>
 *
 * @author wyn
 * @since 2023-02-13
 */
@Service
public class WjSupplierServiceImpl extends ServiceImpl<WjSupplierMapper, WjSupplier> implements IWjSupplierService {

    @Autowired
    WjSupplierMapper wjSupplierMapper;

    @Override
    public int addBase(WjSupplier wjSupplier) {
        /*Integer id = wjSupplier.getId();
        WjSupplier data = wjSupplierMapper.selectById(id);
        if (data !=null){
            wjSupplierMapper.deleteById(data.getId());
        }*/
        //wjSupplierMapper.delete(new QueryWrapper<>());
        int i = wjSupplierMapper.insert(wjSupplier);
        return i;
    }

    @Override
    public List<String> getID() {
        List<WjSupplier> wjSuppliers = wjSupplierMapper.selectList(null);
        List<String> idlist =new ArrayList();
        for (WjSupplier wjSupplier : wjSuppliers) {
            idlist.add(String.valueOf(wjSupplier.getId()));
        }
        return idlist;
    }

    @Override
    public List<WjSupplierName> getBaseNames() {

        return wjSupplierMapper.getBaseNames();
    }
}
